<!-- 实训任务 -->
<template>
  <div>
    <el-tabs type="border-card" class="demo-tabs" v-model="curtab">
      <el-tab-pane name="first">
        <template #label>
          <span class="custom-tabs-label">
            <!-- <el-icon><calendar /></el-icon> -->
            <span class="circle" :class="{ currentcircle: curtab == 'first' }"></span>
            <span>仿真练习</span>
          </span>
        </template>

        <!-- 状态描述 -->
        <div class="describe behindbox">
          <i>&#xe72d;</i>
          <span style="margin-right: 50px">已完成</span>
          <i>&#xe636;</i>
          <span>未完成</span>
          <span style="margin-left: 770px">发布时间</span>
        </div>

        <!-- 仿真练习列表 -->
        <ul class="ulbox">
          <!-- @click="openTrainSum(666)" -->
          <li @click="openEmulationSum(item.id)" v-for="(item, index) in emulationlist" :key="index">
            <div class="iconcontainer behindbox">
              <i v-show="true">&#xe72d;</i>
              <i v-show="false">&#xe636;</i>
            </div>
            <p>{{ item.title }}</p>
            <p class="publishtime">发布时间：{{ item.create_time }}</p>
            <!-- <span class="statuslabel">进行中</span> -->
          </li>
        </ul>
      </el-tab-pane>
      <el-tab-pane name="second">
        <template #label>
          <span class="custom-tabs-label">
            <span class="circle" :class="{ currentcircle: curtab == 'second' }"></span>
            <span>仿真测试</span>
          </span>
        </template>

        <!-- 状态描述 -->
        <div class="describe behindbox">
          <i>&#xe72d;</i>
          <span style="margin-right: 50px">已完成</span>
          <i>&#xe636;</i>
          <span>未完成</span>
          <span style="margin-left: 770px">发布时间</span>

        </div>

        <!-- 考试列表 -->
        <ul class="ulbox">
          <li data-eid="11">
            <div class="iconcontainer behindbox">
              <i v-show="true">&#xe72d;</i>
              <i v-show="false">&#xe636;</i>
            </div>
            <p>仿真2</p>
            <p class="publishtime">发布时间：2024-09-29 14:14:00</p>
          </li>
        </ul>
      </el-tab-pane>

    </el-tabs>

    <el-dialog v-model="dialogEmulationVisible" :width="600">
      <div class="studentinfo">
        <div class="status">
          <p>已完成</p>
        </div>
        <div class="examinfo">
          <p>电动机单向连续运转接线(带电动控制)</p>
          <div class="score">
            <span>技能分&nbsp;<em>80</em>&nbsp;分</span>
            <span>素养分&nbsp;<em>80</em>&nbsp;分</span>
          </div>
        </div>
        <div class="name_class">
          <ul>
            <li>
              <div class="labelbox">姓名：</div>
              <div class="contentbox">luffygo</div>
            </li>
            <li>
              <div class="labelbox">小组：</div>
              <div class="contentbox">第三组</div>
            </li>
            <li>
              <div class="labelbox">工位：</div>
              <div class="contentbox">设备3</div>
            </li>
          </ul>
        </div>
        <div class="btnbox">
          <el-button type="primary" class="btnstyle" @click="gotoTrainDetail">查询实训详情</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, onMounted, inject, defineProps } from 'vue'

// 导入请求路径
import api from '@/request/api'
// 注入网络请求方法
const axios = inject('axios')

import { useRouter } from 'vue-router'
// 初始化路由实例
const router = useRouter()

// 加载user模块 以及底下变量
import { storeToRefs } from 'pinia'
import useStore from '@/store'
const { user } = useStore()
let { username, avatar, uid } = storeToRefs(user)

// 定义props
const props = defineProps({
  lessonid: {
    default: 0,
    required: true,
    type: Number
  }
})

// 模态框显示标识
const dialogEmulationVisible = ref(false)
let curtab = ref('first')
let emulationlist = ref([])

onMounted(async () => {
  console.log('props.lessonid', props.lessonid)

  await getEmulationList()
})

// 获取仿真列表
async function getEmulationList(lesson_id) {
  let res = await axios.post(api.emulationmylist, {
    uid: uid.value,
  })

  console.log(res);
  if (res.code == 0) {
    emulationlist.value = res.data
  } else return showMessage('error', res.msg)
}
// 打开仿真详情
async function openEmulationSum(mid) {
  console.log(mid);
  let res = await axios.post(api.emulationbasedetail, {
    uid: uid.value,
    id: mid
  })

  console.log(res);

  // dialogEmulationVisible.value = true
}

// 跳转考试详情
function gotoTrainDetail(eid) {
  console.log(eid);

  // 新页面打开
  // const hrefstr = router.resolve({
  //   name: 'Examdetail',
  //   state: {
  //     eid
  //   }
  // }).href
  // window.open(hrefstr, '_blank')
}

// 信息提示
const showMessage = (msgtype, msgstr) => {
  ElMessage({
    showClose: true,
    message: msgstr,
    type: msgtype,
    offset: 50
  })
}

</script>

<style scoped>
.demo-tabs>.el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}

.demo-tabs .custom-tabs-label .el-icon {
  vertical-align: middle;
}

.demo-tabs .custom-tabs-label span {
  vertical-align: middle;
  margin-left: 4px;
}

.circle {
  box-sizing: border-box;
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 4px;
  /* background-color: skyblue; */
  border: 1px solid skyblue;
}

.describe {
  display: flex;
  align-items: center;
  height: 30px;
  margin-bottom: 20px;
}

.describe span {
  font-weight: 700 !important;
}


.currentcircle {
  background-color: skyblue;
  border: 0;
}

.behindbox i {
  display: block;
  font-family: 'iconfont2' !important;
  font-size: 16px;
  color: #afc5cc;
  margin-right: 10px;
}

.ulbox li {
  display: flex;
  align-items: center;
  height: 40px;
  /* background-color: pink; */
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.ulbox li p {
  width: 750px;
  margin-right: 150px;
}

.statuslabel {
  font-size: 14px;
}

.studentinfo {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  /* height: 150px; */
  margin: 0 auto;
  /* background-color: pink; */
  padding-top: 20px;
}

.studentinfo ul li {
  display: flex;
  height: 28px;
  margin: 0px auto;
  align-items: center;
}

.examinfo {
  width: 70%;
  height: 100px;
  margin: 0 auto;
  /* background-color: skyblue; */
  padding-top: 20px;
}

.examinfo p {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.examinfo .score {
  width: 60%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px auto 0;
}

.examinfo .score em {
  font-size: 20px;
}

.name_class {
  box-sizing: border-box;
  width: 280px;
  padding: 10px 20px;
  font-size: 14px !important;
  background-color: #f2f2f2;
}

.name_class .contentbox {
  font-weight: 550;
}

.btnbox {
  text-align: center;
  margin-top: 40px;
  margin-bottom: 90px;
}

.btnstyle {
  width: 200px;
  margin: 0 auto;
}

.studentinfo .status {
  width: 240px;
  height: 100%;
  text-align: center;
}

.studentinfo .status p {
  color: #0099fe;
  font-size: 30px;
  font-weight: 700;
}
</style>

<style scoped>
.ulbox li .publishtime {
  width: 260px;
  font-size: 14px;
  margin-right: 0px;
}
</style>
